package cn.z2huo.knowledge.jdk8.designpattern.proxy.dynamic.example3;

/**
 * <p>
 *
 * @author z2huo
 */
public class ServiceImpl implements MyService, MyService2 {

    @Override
    public void request() {
        System.out.println("request");
    }

    @Override
    public void response() {
        System.out.println("response");
    }

    @Override
    public void say() {
        System.out.println("say");
    }

    @Override
    public void run() {
        System.out.println("run");
    }

    public static void main(String[] args) {
        ServiceImpl myService = new ServiceImpl();
        Object proxy = MyInvocationHandler.getProxy(new Class[]{MyService.class, MyService2.class}, myService);

        MyService myServiceProxy = (MyService) proxy;
        MyService2 myService2Proxy = (MyService2) proxy;

        myServiceProxy.request();
        System.out.println();
        myServiceProxy.response();

        System.out.println();

        myService2Proxy.run();
        System.out.println();
        myService2Proxy.say();

    }
}
